﻿<Window x:Class="WPF.DataBinding.HierarchicalBindings.HierBindingWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="HierBindingWindow" Height="300" Width="300">
    <Grid>
        <Grid.Resources>
            <XmlDataProvider x:Key="src" XPath="/myDoc/Item">
                <x:XData>
                    <myDoc xmlns=''>
                        <item title="One"/>
                        <item title="Two">
                            <item title="2.1"/>
                            <item title="2.2"/>
                            <item title="2.3"/>
                            <item title="2.4">
                                <item title="2.1.1"/>
                                <item title="2.1.2"/>
                                <item title="2.1.3"/>
                                <item title="2.1.4">
                                    <item title="2.1.4.1"/>
                                    <item title="2.1.4.2"/>
                                    <item title="2.1.4.3"/>
                                    <item title="2.1.4.4"/>
                                </item>
                            </item>
                        </item>
                        <item title="Three"/>
                    </myDoc>
                </x:XData>
            </XmlDataProvider>
        </Grid.Resources>
        <TreeView DataContext="{StaticResource ResourceKey=src}" ItemsSource="{Binding Path=myDoc}">
            <TreeView.ItemTemplate>
                <HierarchicalDataTemplate ItemsSource="{Binding XPath=item}">
                    <TextBlock Text="{Binding XPath=@title}"/>
                </HierarchicalDataTemplate>
            </TreeView.ItemTemplate>
        </TreeView>
    </Grid>
</Window>
